package com.example.springbootlearn.concurrent;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author caiji Mr. Li
 * @date 2019/10/23 15:42
 */
public class AQSConditionTest {
    public static void main(String[] args) {
        ReentrantLock lock =new ReentrantLock();
        Condition condition = lock.newCondition();

        lock.lock();
        try {
            System.out.println("begin wait");
            condition.await();
            System.out.println("end wait");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            lock.unlock();
        }

        lock.lock();
        try {
            System.out.println("begin signal");
            condition.signal();
            System.out.println("end signal");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }
}
